<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Infotech Ltd.
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2005/08/07 05:20:29 $)
// $RCSfile: setup_step1.php,v $ : $Revision: 1.7 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	// File being called directly, end it
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

displayHeader();

// Although we created dbCore with hope of making a build that uses ADODB, we will not initiate it as we will be using mySQL for some time (ADODB loads 4-5 files causing unecessary load on servers with lot of visitors who use liveresponse and besides, its not true abstraction anyway, one thing or another needs to be changed in structure.. oh well!
displayValue("Product:", SWIFTPRODUCT);
displayValue("Version:", SWIFTVERSION);
displayValue("Build Date:", BUILDDATE);
displayValue("Build Type:", BUILDTYPE);
displayStatus("Verifying Database Connection", $dbCore->connected, $dbCore->fetchLastError());

if ($dbCore->connected)
{
	require_once ("./setup/steps/global_systemchecks.php");

	// ======= Continue With Other Stuff =======
	if ($_SWIFT["setupfailed"] != true)
	{
		// ok db was also selected, lets see if it is empty?
		if ($_POST["submitbutton"] == "Empty Database")
		{
			displayStatusList(setup_cleardb());
		}

		$tableResult = $dbCore->queryFetch("SHOW TABLE STATUS;");
		$hastables = false;

		if (is_array($tableResult))
		{
			$_SWIFT["hastables"] = true;
			displayMessage("Database is not empty, Please click Empty Database to delete all existing tables or click Continue to proceed with the setup. It is strongly recommended that you empty the database or the setup process might fail.");
		}
	} else {
		$_SWIFT["error"] = true;		
	}
} else {
	$_SWIFT["error"] = true;
}
displayFooter();
?>